import Base from '../main/Base';
import Fs from './FundStatus';
export default class progress {
    constructor(data) {
        this.data = data;
        this.cmp = {
            fundStatus: new Fs(data)
        }
        this.sts = {
            congrats: 'congrats'
        }
    }

    static renderOut(className) {
        let _ = require('../middleware/utils');
        _.e = _.str2class;
        let that = this;
        _.get('http://54.223.238.147:910/get_photo_detail_history', function (data) {
            var pd = JSON.parse(data);
            if (pd && pd['is_full']) {
                _.$(_.e(that.sts.congrats)).classList.add('show');
            }
            if (pd.status !== 1) {
                Base.render(`<div>${pd.msg}</div>`, className, 'inner');
            }
            else
                Base.render(new progress(pd), className, 'inner');
        });
    }

    render() {
        return `
        <div style="background-color:#000000;padding:5px 0px;">
            <div class="return_progress_img"></div>
        </div>
        <div class="stickTop">
            <div class="banner_stickTop_img"></div>
            <div class="fund_stickTop_container">
                <div class="columns"><div class="done_container_fund">${this.data['sum_number']}(人)<div class="suffix_done_helper">已拍书捐爱心</div></div></div>
                <div class="columns"><div class="predict_container_fund">30000(元)<div class="suffix_predict_helper">预计筹款数目</div></div></div>
            </div>
        </div>
        <div class="eventDetail show">
         <!--   <div class="stick_eventDetail_container">
                <div class="icon_eventDetail_img"></div>
                <span class="title_eventDetail_text">活动详情</span>
                <div class="arrow_eventDetail_img"></div>
            </div>-->
            <div class="intro_eventDetail_text">
                           你拍下一本书籍封面，宁波印象城会代你捐1元送给偏乡孩子作为读书基金。收集超过3万本，我们将通过狮子会向江北甬城学校捐献价值3万元书资。

            </div>
        </div>
        <div class="loveFront">
          <div class="stick_loveFront_container">
                <div class="icon_loveFront_img"></div>
                <span class="title_loveFront_text">爱心前线</span>
            </div>
            ${this.cmp.fundStatus.render()}
        </div>
        <div class="congrats">
    <div class="reach_congrats_img"></div>
    <div class="btn_congrats_img"></div>
</div>
        `;
    }

    listen() {
        let _ = require('../middleware/utils');
        return [{
            momId: '.mom',
            uid: '.btn_congrats_img',
            ontouchstart(binded){
                let b = _.$('.congrats');
                b.classList.remove('show');
            }
        }, {
            momId: '.progress_mom_placeholder',
            uid: '.return_progress_img',
            oppressId: '.progress_mom_placeholder',
            ontouchstart(binded, evt, oppressId){
                let op = _.$(oppressId);
                let classes = op.classList;
                if (classes.contains('show')) {
                    op.classList.remove('show');
                }
            }
        }]
    }
}
